/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tletlis.model;

import java.awt.Color;

/**
 * A class that represents the positions on the gameboard. Evey position can be
 * either free or not. Every position also has a color.
 * @author Gustav
 */
public class GamePosition extends Position {
    
    private boolean free = true;
    private Color color = Color.BLACK;

  /**
   * Creates a new position
   * @param y
   * @param x
   */
    public GamePosition(int y, int x) {
        super(y,x);
    }

  /**
   * Returns the color of the position.
   * @return Color
   */
    public Color getColor() {
        return color;
    }

  /**
   * Returns true if the position is not occupied by a brick.
   * @return boolean
   */
    public boolean isFree() {
        return free;
    }

  /**
   * Method that clears a position, which means painting it black and setting
   * its free boolean to true.
   */
    public void clear() {
        free = true;
        color =Color.BLACK;
    }

  /**
   * Method that sets a position, which means painting it in some color.
   * Clears the position if the color supposed to paint with is black.
   * @param c The color used to paint with.
   */
    public void set(Color c) {
        
        if(c == Color.BLACK)
            clear();
        else {
            free = false;
            color = c;
        }
    }

  /**
   * Returns true if the parameter object has the same x and y values as
   * the game position.
   * @param o The object to be compared.
   * @return boolean
   */
    @Override
    public boolean equals(Object o) {
        return super.equals(o);
    }

  /**
   * Returns "x,y"
   * @return String
   */
    public String toString() {
        return super.toString();
    }

}
